package com.hongkzh.www.look.view.activity;

import android.content.Intent;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.widget.Button;

import com.hongkzh.www.R;
import com.hongkzh.www.look.enterprise.presenter.StartPresenter;
import com.hongkzh.www.view.activity.BaseActivity;
import com.hongkzh.www.look.view.iview.StartIView;

/**
 * 类作用：启动页
 */

public class MyStartActivity extends BaseActivity<StartPresenter> implements StartIView, View.OnClickListener {


    private Button button;
    private boolean isCheck;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_start;
    }

    @Override
    protected void init() {
        button = findViewById(R.id.button);

        new Handler(new Handler.Callback() {
            @Override
            public boolean handleMessage(Message msg) {
                if (isCheck) {
                    return true;
                } else {
                    startActivity(new Intent(getApplicationContext(), MainActivity.class));
                    finish();
                    return false;
                }
            }
        }).sendEmptyMessageDelayed(0, 3000);
    }

    @Override
    protected void setListener() {
        button.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.button:
                isCheck = true;
                Intent intent = new Intent(getApplicationContext(), MainActivity.class);
                startActivity(intent);
                finish();
                break;
        }
    }

    @Override
    public void onError(Exception e) {

    }
}
